package com.tsingteng.cosfun.ui.login;

import com.tsingteng.cosfun.app.App;
import com.tsingteng.cosfun.bean.ReportBean;
import com.tsingteng.cosfun.bean.UserBean;
import com.tsingteng.cosfun.callback.RxObserver;
import com.tsingteng.cosfun.http.RxSchedulers;
import com.tsingteng.cosfun.mvp.module.BaseModel;
import com.tsingteng.cosfun.utils.TimeUtils;

/**
 * 描述 :
 * 创建人: 肖利.
 * 时间:2018/8/8
 * qq(872179966)
 */

public class LogonModel extends BaseModel implements ILoginModel{

    /**
     *登录
     * @param mobile
     * @param verifyCode
     * @param timestamp
     * @param callback
     */
    @Override
    public void login(String mobile, String verifyCode, String timestamp, RxObserver<UserBean> callback) {
        doRxRequest().login(mobile,verifyCode,timestamp).compose(RxSchedulers.io_main()).subscribe(callback);
    }


    /**
     * 验证码
     * @param mobile
     * @param verifyType
     * @param timestamp
     * @param callback
     */
    @Override
    public void verfyCode(String mobile, String verifyType, String timestamp, RxObserver<UserBean> callback) {
        doRxRequest().verifyCode(mobile,verifyType,timestamp).compose(RxSchedulers.io_main()).subscribe(callback);
    }


    /**
     * 三登录
     * @param open_id
     * @param thirdparty_token
     * @param timestamp
     * @param login_type
     * @param headpic
     * @param nickname
     * @param callback
     */
    @Override
    public void logonQQ(String open_id, String thirdparty_token,String timestamp,String login_type,String headpic,String nickname,RxObserver<UserBean> callback) {
        doRxRequest().getQQLogon(open_id,thirdparty_token,timestamp,login_type,headpic,nickname).compose(RxSchedulers.io_main()).subscribe(callback);
    }

    /**
     * 友盟登录上报
     *
     * @param rxObserver*/
    @Override
    public void getLoginAndReport(RxObserver<ReportBean> rxObserver) {
        doRxRequest().getLoginAndReport(App.getDeviceToken(),"1", TimeUtils.getCurTimeLong()+"").compose(RxSchedulers.io_main()).subscribe(rxObserver);
    }
}
